package dataflowScheme.diagram.part;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteGroup;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;

/**
 * @generated
 */
public class ModelPaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createNodes1Group());
		paletteRoot.add(createPortsPortSets2Group());
		paletteRoot.add(createConnections3Group());
	}

	/**
	 * Creates "Nodes" palette tool group
	 * @generated
	 */
	private PaletteContainer createNodes1Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				dataflowScheme.diagram.part.Messages.Nodes1Group_title);
		paletteContainer.add(createTrigger1CreationTool());
		paletteContainer.add(createStopper2CreationTool());
		paletteContainer.add(createTask3CreationTool());
		paletteContainer.add(createStorage4CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Ports / PortSets" palette tool group
	 * @generated
	 */
	private PaletteContainer createPortsPortSets2Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				dataflowScheme.diagram.part.Messages.PortsPortSets2Group_title);
		paletteContainer.add(createDataPort1CreationTool());
		paletteContainer.add(createSynchroPort2CreationTool());
		paletteContainer.add(createPortSet3CreationTool());
		return paletteContainer;
	}

	/**
	 * Creates "Connections" palette tool group
	 * @generated
	 */
	private PaletteContainer createConnections3Group() {
		PaletteDrawer paletteContainer = new PaletteDrawer(
				dataflowScheme.diagram.part.Messages.Connections3Group_title);
		paletteContainer.add(createSynchronizationconnection1CreationTool());
		paletteContainer.add(createDataconnection2CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createTrigger1CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.Trigger_1003);
		NodeToolEntry entry = new NodeToolEntry(
				dataflowScheme.diagram.part.Messages.Trigger1CreationTool_title,
				dataflowScheme.diagram.part.Messages.Trigger1CreationTool_desc,
				types);
		entry
				.setSmallIcon(dataflowScheme.diagram.providers.ModelElementTypes
						.getImageDescriptor(dataflowScheme.diagram.providers.ModelElementTypes.Trigger_1003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createStopper2CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.Stopper_1004);
		NodeToolEntry entry = new NodeToolEntry(
				dataflowScheme.diagram.part.Messages.Stopper2CreationTool_title,
				dataflowScheme.diagram.part.Messages.Stopper2CreationTool_desc,
				types);
		entry
				.setSmallIcon(dataflowScheme.diagram.providers.ModelElementTypes
						.getImageDescriptor(dataflowScheme.diagram.providers.ModelElementTypes.Stopper_1004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createTask3CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types.add(dataflowScheme.diagram.providers.ModelElementTypes.Task_1002);
		NodeToolEntry entry = new NodeToolEntry(
				dataflowScheme.diagram.part.Messages.Task3CreationTool_title,
				dataflowScheme.diagram.part.Messages.Task3CreationTool_desc,
				types);
		entry
				.setSmallIcon(dataflowScheme.diagram.providers.ModelElementTypes
						.getImageDescriptor(dataflowScheme.diagram.providers.ModelElementTypes.Task_1002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createStorage4CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.Storage_1001);
		NodeToolEntry entry = new NodeToolEntry(
				dataflowScheme.diagram.part.Messages.Storage4CreationTool_title,
				dataflowScheme.diagram.part.Messages.Storage4CreationTool_desc,
				types);
		entry
				.setSmallIcon(dataflowScheme.diagram.providers.ModelElementTypes
						.getImageDescriptor(dataflowScheme.diagram.providers.ModelElementTypes.Storage_1001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDataPort1CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(2);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.DataPort_2002);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.DataPort_2005);
		NodeToolEntry entry = new NodeToolEntry(
				dataflowScheme.diagram.part.Messages.DataPort1CreationTool_title,
				dataflowScheme.diagram.part.Messages.DataPort1CreationTool_desc,
				types);
		entry
				.setSmallIcon(dataflowScheme.diagram.providers.ModelElementTypes
						.getImageDescriptor(dataflowScheme.diagram.providers.ModelElementTypes.DataPort_2002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createSynchroPort2CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(4);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.SynchroPort_2003);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.SynchroPort_2006);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.SynchroPort_2007);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.SynchroPort_2008);
		NodeToolEntry entry = new NodeToolEntry(
				dataflowScheme.diagram.part.Messages.SynchroPort2CreationTool_title,
				dataflowScheme.diagram.part.Messages.SynchroPort2CreationTool_desc,
				types);
		entry
				.setSmallIcon(dataflowScheme.diagram.providers.ModelElementTypes
						.getImageDescriptor(dataflowScheme.diagram.providers.ModelElementTypes.SynchroPort_2003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createPortSet3CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(2);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.PortSet_2001);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.PortSet_2004);
		NodeToolEntry entry = new NodeToolEntry(
				dataflowScheme.diagram.part.Messages.PortSet3CreationTool_title,
				dataflowScheme.diagram.part.Messages.PortSet3CreationTool_desc,
				types);
		entry
				.setSmallIcon(dataflowScheme.diagram.providers.ModelElementTypes
						.getImageDescriptor(dataflowScheme.diagram.providers.ModelElementTypes.PortSet_2001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createSynchronizationconnection1CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.SynchroConnection_3001);
		LinkToolEntry entry = new LinkToolEntry(
				dataflowScheme.diagram.part.Messages.Synchronizationconnection1CreationTool_title,
				dataflowScheme.diagram.part.Messages.Synchronizationconnection1CreationTool_desc,
				types);
		entry
				.setSmallIcon(dataflowScheme.diagram.providers.ModelElementTypes
						.getImageDescriptor(dataflowScheme.diagram.providers.ModelElementTypes.SynchroConnection_3001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDataconnection2CreationTool() {
		List/*<IElementType>*/types = new ArrayList/*<IElementType>*/(1);
		types
				.add(dataflowScheme.diagram.providers.ModelElementTypes.DataConnection_3002);
		LinkToolEntry entry = new LinkToolEntry(
				dataflowScheme.diagram.part.Messages.Dataconnection2CreationTool_title,
				dataflowScheme.diagram.part.Messages.Dataconnection2CreationTool_desc,
				types);
		entry
				.setSmallIcon(dataflowScheme.diagram.providers.ModelElementTypes
						.getImageDescriptor(dataflowScheme.diagram.providers.ModelElementTypes.DataConnection_3002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(String title, String description,
				List elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(String title, String description,
				List relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
